package com.tonicgb.api.admin.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tonicgb.mapper.AdminsMapper;
import com.tonicgb.model.Admins;
import com.tonicgb.model.Bean;
import com.tonicgb.service.AdminService;
import com.tonicgb.shared.annotation.ApiResponse;
import com.tonicgb.shared.annotation.PassToken;
import com.tonicgb.shared.core.crud.entity.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@Controller
@RequestMapping("${adminPath}/test")
@Api(value = "web测试用例",tags = "测试用列")
public class TestController implements RestController {


    @Autowired
    private AdminService adminService;

    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private AdminsMapper adminsMapper;

    @PostMapping("/test")
    @ApiResponse
    @ApiOperation("test 测试方法")
    @PassToken
    public Object test(@RequestBody Admins admins){

        Page<Admins> page=adminService.findPage(admins);
        return page;
    }

    @GetMapping("/test2")
    @ApiResponse
    @ApiOperation("test 测试方法")
    @PassToken
    public Object test2(){
        Admins admins=new Admins();

        //admins.setStatus("1");
        Page<Admins> page=adminService.findPage(admins);
       // PageHelper.startPage(1, 10);
        //List<Admins> admin= adminsMapper.getAll();
      //  return ResultPage.restPage(admin);
        return  page;
    }


    @PostMapping("/jackson")
    @ResponseBody
    @ApiOperation("jackson 测试方法")
    @PassToken
    public Object jackson(@RequestBody Bean beans){
        System.out.println(beans.toString());
        Bean bean = new Bean("haha1", new BigDecimal("1.00"),new BigDecimal("2"),new BigDecimal("3.00"));
        //return bean;
        return bean;
    }

}
